package com.genshang.restaurant.controller;


import com.genshang.restaurant.result.ResultBody;
import com.genshang.restaurant.service.ICustomerlistService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Alex
 * @since 2020-07-28
 */
@RestController
@RequestMapping("/customerlist/")
public class CustomerlistController {

    Logger logger = LoggerFactory.getLogger(CustomerlistController.class);

    @Autowired
    private ICustomerlistService customerlistService;

    /**
     * 通过openid获取用户信息
     *
     * @param phone
     * @return
     */
    @GetMapping("/getCustomerByOpenId")
    public ResultBody getCustomerByOpenId(String phone) {
        logger.info("获取用户信息 opId = " + phone);
        return ResultBody.success(customerlistService.getCustomerByPhone(phone));
    }

    /**
     * 2. 获取累计积分
     *
     * @param phone
     * @return
     */
    @GetMapping("/getTotalScores")
    public ResultBody getTotalScores(String phone) {
        return customerlistService.getTotalScores(phone);
    }
}
